## general behaviour
# Keep the same indentation after ENTER
set autoindent
# 72 character width paragraphs
set fill 72
set tabsize 8
# Use Ctrl-J to justify paragraphs, Ctrl-U to unjustify
set nowrap
# Show cursor position constantly
set constantshow
# First HOME returs to end of first whitespace, second to start of line
set smarthome
# Allow opening of multiple files in different buffers
set multibuffer


## syntax highlighting for bash scripts
syntax "sh" "\.sh$"
header "^#!.*/(ba|k|pdk)?sh[-0-9_]*"
icolor brightgreen "^[0-9A-Z_]+\(\)"
color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color green "-[Ldefgruwx]\>"
color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
color brightblue "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|install|let|ln|make|mkdir|mv|rm|sed|set|tar|touch|umask|unset)\>"
icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color cyan "(^|[[:space:]])#.*$"
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
color ,green "[[:space:]]+$"


## syntax highlighting for C/C++
syntax "c" "\.(c(c|pp|xx)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
color brightred "\<[A-Z_][0-9A-Z_]+\>" 
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\>"
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
## GCC builtins
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
## String highlighting.  You will in general want your comments and
## strings to come last, because syntax highlighting rules will be
## applied in the order they are read in.
color brightyellow "<[^= 	]*>" ""(\\.|[^"])*""
## This string is VERY resource intensive!
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
## Comment highlighting
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
## Trailing whitespace
color ,green "[[:space:]]+$"


## syntax highlighting for HTML and MathJax
syntax "html" "\.html?$"
#<!-- reserved for comments, "< " might be just comparison in JS
color cyan start="<[^! =]" end=">"
#but <!doctype html> should be cyan
icolor cyan start="<!doctype" end=">"
color red "&[^;[:space:]]*;"
color brightcyan ""(\\.|[^"])*""
#seems not possible to avoid \$ or setting it back to default color
color magenta "\\\(|\\\)|\\\[|\\\]|\$"
#anything of the form "\begin{...}" or "\end{...}"
color magenta "\\begin\{[^\}]*\}|\\end\{[^\}]*\}"
color brightblue start="<!--" end="-->"


## syntax highlighting for CSS
syntax "css" "\.css$"
color brightred     "."
color brightyellow  start="\{" end="\}"
color brightwhite   start=":" end="([;^\{]|$)"
color brightblue    ":active|:focus|:hover|:link|:visited|:link|:after|:before|$"
color brightblue    start="\/\*" end="\\*/"
color green         ";|:|\{|\}"


## syntax highlighting for TeX
syntax "tex" "\.tex$" "\.bib$"
#icolor cyan "\\.|\\[A-Z]*"
color cyan "\\(documentclass|usepackage|theoremstyle|newtheorem)"
color cyan "\\(DeclareMathOperator|newcommand|renewcommand|maketitle)"
color cyan "\\(emph|addcontentsline|bibitem|cite|ref|eqref|label|pageref)"
color cyan "\\(numberwithin)"
color brightcyan "\\(title|author|date|section|subsection|subsubsection)"
#but <!doctype html> should be cyan
icolor cyan start="<!doctype" end=">"
color brightcyan ""(\\.|[^"])*""
#seems not possible to avoid \$ or setting it back to default color
color magenta "\\\(|\\\)|\\\[|\\\]|\$"
#anything of the form "\begin{...}" or "\end{...}"
color magenta "\\begin\{[^\}]*\}|\\end\{[^\}]*\}"
#comments
color brightblue "(|[^\])%.*"


## syntax highlighting for nanorc
syntax "nanorc" "\.?nanorc$"
## Possible errors and parameters
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
## Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\>"
icolor green "^[[:space:]]*(set|unset|include|syntax|header)\>"
## Colors
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
## Strings
icolor white ""(\\.|[^"])*""
## Comments
icolor brightblue "^[[:space:]]*#.*$"
icolor cyan "^[[:space:]]*##.*$"


## syntax highlighting for JavaScript
syntax "javascript" "\.js$"
color brightred "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(const|function|let|this|typeof|var|void)\>"
color brightyellow "\<(for|if|while|with|do|else|case|default|switch)\>"
color brightyellow "\<(export|try|throw|catch|new|delete)\>"
color magenta "\<(continue|break|return|yield)\>"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
# Strings.
color brightyellow "<[^=        ]*>" ""(\\.|[^"])*"" "'(\\.|[^'])*'"
# Trailing whitespace.
color ,green "[[:space:]]+$"


## syntax highlighting for Asymptote
syntax "asy" "\.asy$"
color brightred "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(real|pair|triple|bool|bool3|int|static|struct|typedef|string)\>"
color green "\<(path|path3|guide|guide3|surface|pen|material|transform|frame)\>"
color green "\(picture|file)\>"
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightcyan "\<(import|from|access|unravel|as)\>"
# Strings.  In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.
color brightyellow "<[^= 	]*>" ""(\\.|[^"])*""
# Multiline strings.  This regex is VERY resource intensive!
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
# Reminders.
color ,yellow "(FIXME|TODO|XXX)"
# Trailing whitespace.
color ,white "[[:space:]]+$"

